package com.nf.recruitment.controller;

import com.nf.recruitment.entity.Degree;
import com.nf.recruitment.entity.Department;
import com.nf.recruitment.service.DegreeService;
import com.nf.recruitment.service.DepartmentService;
import com.nf.recruitment.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/department")
public class DepartmentController extends BaseController {
    @Autowired
    private DepartmentService service;

    @GetMapping("/list")
    public ResultVO<List<Department>> listDepartment() {
        List<Department> departments = service.listDepartment();

        return new ResultVO<>(200, "", departments);
    }

    @PostMapping("/save")
    public ResultVO saveDegree(@RequestBody Department dto) {
        service.saveDepartment(dto);
        return success();
    }
}
